<template>
  <div class="demo">
    <div class="demo-title">日期格式</div>
    <div class="demo-content">
      <Space direction="vertical" :size="12">
        <DatePicker v-model:value="value1" :format="dateFormat" />
        <DatePicker v-model:value="value2" :format="dateFormatList" />
        <DatePicker v-model:value="value3" :format="monthFormat" picker="month" />
        <DatePicker.RangePicker v-model:value="value4" :format="dateFormat" />
        <DatePicker v-model:value="value5" :format="customFormat" />
        <DatePicker v-model:value="value6" :format="customWeekStartEndFormat" picker="week" />
      </Space>
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import dayjs, { Dayjs } from 'dayjs';
  import Space from '@sscd/space';
  import DatePicker from '@sscd/date-picker';
  const dateFormat = 'YYYY/MM/DD';
  const monthFormat = 'YYYY/MM';
  const dateFormatList = ['DD/MM/YYYY', 'DD/MM/YY'];
  const weekFormat = 'MM/DD';
  const customFormat = (value) => `custom format: ${value.format(dateFormat)}`;
  const customWeekStartEndFormat = (value) =>
    `${dayjs(value).startOf('week').format(weekFormat)} ~ ${dayjs(value)
      .endOf('week')
      .format(weekFormat)}`;
  const value1 = ref<Dayjs>(dayjs('2015/01/01', dateFormat));
  const value2 = ref<Dayjs>(dayjs('01/01/2015', dateFormatList[0]));
  const value3 = ref<Dayjs>(dayjs('2015/01', monthFormat));
  const value4 = ref<[Dayjs, Dayjs]>([
    dayjs('2015/01/01', dateFormat),
    dayjs('2015/01/01', dateFormat),
  ]);
  const value5 = ref<Dayjs>(dayjs('2015/01/01', dateFormat));
  const value6 = ref<Dayjs>(dayjs());
</script>
